package com.zbkj.crmeb.user.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.common.PageParamRequest;
import com.github.pagehelper.PageInfo;
import com.zbkj.crmeb.chant.model.ChannelMemberLevel;
import com.zbkj.crmeb.chant.model.ChannelMerchant;
import com.zbkj.crmeb.front.request.*;
import com.zbkj.crmeb.front.response.LoginResponse;
import com.zbkj.crmeb.front.response.UserCenterResponse;
import com.zbkj.crmeb.front.response.UserSpreadPeopleItemResponse;
import com.zbkj.crmeb.store.model.StoreOrder;
import com.zbkj.crmeb.store.model.StoreOrderInfo;
import com.zbkj.crmeb.store.request.RetailShopStairUserRequest;
import com.zbkj.crmeb.user.model.User;
import com.zbkj.crmeb.user.model.UserMemberLevelRecord;
import com.zbkj.crmeb.user.request.*;
import com.zbkj.crmeb.user.response.TopDetail;
import com.zbkj.crmeb.user.response.UserLevelResponse;
import com.zbkj.crmeb.user.response.UserResponse;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 服务类
 * </p>
 *
 * @author Mr.Zhang
 * @since 2020-04-10
 */
public interface UserService extends IService<User> {
    PageInfo<UserResponse> getList(UserSearchRequest request, PageParamRequest pageParamRequest);

    boolean updateFounds(UserOperateFundsRequest request, boolean isSaveBill);

    boolean updateIntegralMoney(UserOperateIntegralMoneyRequest request);

    /**
     * 用户基本更新
     * @param user 用户参数
     * @return 更新结果
     */
    boolean updateBase(User user);

    /**
     * 用户基本更新
     * @param user 用户参数
     * @return 更新结果
     */
    boolean updateForBuyMember(User user);

    void userPayCountPlus(User user);
    User saveUser(RegisterRequest request, String ip);
    /**
     * 更新余额
     * @param userId 用户id
     * @param price 余额
     * @return 更新后的用户数据
     */
    boolean updateNowMoney(int userId, BigDecimal price);

    boolean group(String id, String groupId);

    boolean cleanLevel(Integer userId);

    LoginResponse register(RegisterRequest loginRequest, String ip);

    LoginResponse login(LoginRequest loginRequest);

    boolean password(PasswordRequest request);

    void loginOut(String token);

    User getInfo();
    
    /**
     * 获取当前用户的token
     * @author daigb
     * @date:  2022-07-25 13:56
     */
    String getInfoToken();

    User getUserPromoter();

    User getInfoException();

    User getInfoEmpty();

    Object getInfoByCondition(Integer userId,Integer type,PageParamRequest pageParamRequest);

    Integer getUserIdException();

    Integer getUserId();

    /**
     * 按开始结束时间查询新增用户数量
     * @param date
     * @param merIds 商户ids
     * @return
     */
    Integer getAddUserCountByDate(String date,List<Integer> merIds);

    Map<Object, Object> getAddUserCountGroupDate(String date,Integer merId);

    boolean bind(UserBindingRequest request);

    UserCenterResponse getUserCenter();

    HashMap<Integer, User> getMapListInUid(List<Integer> uidList);

    HashMap<Integer, User> getMapByList(List<User> list);

    void repeatSignNum(Integer userId);

    //UserCommissionResponse getCommission();

    boolean tag(String id, String tagId);

    List<Integer> getSpreadPeopleIdList(List<Integer> userId);

    List<User> getSpreadPeopleList(List<Integer> userIds);

    /**
     * 根据用户id获取对应用户集合
     * @param userId 用户id
     * @return 用户集合
     */
    List<Integer> getSpreadPeopleIdListByUserId(Integer userId);

    List<UserSpreadPeopleItemResponse> getSpreadPeopleList(List<Integer> userIdList, String keywords, String sortKey, String isAsc, PageParamRequest pageParamRequest);

    TopDetail getTopDetail(Integer userId);

    User registerByThird(RegisterThirdUserRequest thirdUserRequest, String type);

    String token(User user);

    String getValidateCodeRedisKey(String phone);

    boolean spread(Integer currentUserId, Integer spreadUserId);

    PageInfo<User> getUserListBySpreadLevel(RetailShopStairUserRequest request, PageParamRequest pageParamRequest);

    PageInfo<StoreOrder> getOrderListBySpreadLevel(RetailShopStairUserRequest request, PageParamRequest pageParamRequest);

    boolean clearSpread(Integer userId);

    User updateForPromoter(User current);

    boolean checkIsPromoter(BigDecimal price);

    List<User> getTopSpreadPeopleListByDate(String type, PageParamRequest pageParamRequest);

    Integer getCountByPayCount(int minPayCount, int maxPayCount,Integer merId);

    List<User> getUserByEntity(User user);

    void consumeAfterUpdateUserFounds(Integer uid, String storeOrderId, BigDecimal price, String type);

    void bindSpread(User user, Integer spreadPid);

    /**
     * 查询父级下的2级用户
     * @author cyz
     * @date 2021/5/12 16:26
     * @return java.util.List<java.lang.Integer>
     */
    List<Integer> getChildUidList(Integer uid);

    /**
     * 获取用户的商户信息
     * @author cyz
     * @date 2021/5/18 15:52
     * @return java.lang.Integer
     */
    public Integer getUserMerchatId(HttpServletRequest request);

    boolean updateIntegral(UserUpdateIntegralRequest request);

    Object bindingTag(Integer tagId, List<Integer> userIdList, Integer merId);

    Object removeTag(Integer tagId, Integer userId, Integer merId);

    /**
     * 商户批量发放优惠券
     * @param couponId
     * @param userIdList
     * @param merId
     * @return
     */
    Object binCouponUser(Integer couponId, List<Integer> userIdList, Integer merId);

    /**
     * 统计新用户
     * @param date
     * @param merIds
     * @return
     */
    Map<Object, Object> countAddUserGroupDateByMerIds(String date,List<Integer> merIds);

    /**
     * 用户购买统计
     * @param minPayCount
     * @param maxPayCount
     * @param merIds
     * @return
     */
    Integer countPayUserByMerIds(int minPayCount, int maxPayCount,List<Integer> merIds);

    void calcMoney(User userAccount);

    void joinDistribution(StoreOrder storeOrder, StoreOrderInfo storeOrderInfo);

    List<User> getUserResponseList(UserSearchRequest request);

    void addAccountInfoByType(BigDecimal price,Integer uid,Integer tradeType);

    User getPromotionalInformation(Integer id);

    /**
     * 根据手机号和商户id登录
     * @param loginRequest
     * @param ip
     * @return com.zbkj.crmeb.front.response.LoginResponse
     */
    LoginResponse loginByPhoneAndMerId(LoginMobileRequest loginRequest, String ip);

    /**
     * 根据手机号获取用户对应商户id
     * @param phone
     * @return java.util.List<java.lang.Integer>
     */
    List<ChannelMerchant> getMerIdByPhone(String phone);

    void validateCode(String phone,String validateCode);

    /**
     * 获取用户编辑详情
     * @param uid
     * @param merId
     * @return com.zbkj.crmeb.user.response.UserResponse
     */
    UserResponse getUserEditDetails(Integer uid, Integer merId);


    PageInfo<UserLevelResponse> getUserLevelList(UserMemberLevelRequest request, Integer merId);

    ChannelMemberLevel getUserLevelInfo();

    ChannelMemberLevel getUserMemberLevel(User currentUser);

    void updateMemberLevel(ChannelMemberLevel memberLevel, BigDecimal condition, Integer merId);

    boolean addUser(String phone, Integer merId);

    Map<String, List<String>> userExistByPhones(String phones, Integer merId);

}
